/**
 * Orienteering Sport Diary Copyright (C) 2009 OSDiary Team
 *
 * This file is part of Orienteering Sport Diary (OSDiary).
 *
 * OSDiary is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see http://www.gnu.org/licenses/.
 */

package org.actions.race;

import com.opensymphony.xwork2.ActionSupport;   
import java.sql.Time;
import org.data.RunRace;
import org.util.EventDAO;

public class SaveRunRaceAction extends ActionSupport {
    private String eventId;
    private String duration;
    private String distance;
    private String averagePulse;
    private String maxPulse;
    private String minPulse;
    private String climb;
    private String description;
    
    @Override
    public String execute() {
        RunRace rr = new RunRace();
        rr.duration = Time.valueOf(duration);
        rr.distance = Integer.parseInt(distance);
        rr.average_pulse = Integer.parseInt(averagePulse);
        rr.max_pulse = Integer.parseInt(maxPulse);
        rr.min_pulse = Integer.parseInt(minPulse);
        rr.climb = Integer.parseInt(climb);
        rr.description = description;

        EventDAO.addRunRace(Integer.parseInt(eventId), rr);
        
        return SUCCESS;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public void setAveragePulse(String averagePulse) {
        this.averagePulse = averagePulse;
    }

    public void setClimb(String climb) {
        this.climb = climb;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }
    
    public void setDuration(String duration) {
        this.duration = duration;
    }

    public void setMaxPulse(String maxPulse) {
        this.maxPulse = maxPulse;
    }

    public void setMinPulse(String minPulse) {
        this.minPulse = minPulse;
    }
}
